import java.util.Vector;

/**
 * A Bank class
 * @author Sanjeev Kamboj, Travis Drake
 * Assignment 1
 *
 */
public class Bank 
{
	/**
	 * The name of the bank
	 */
	private String fName;
	
	/** The CheckingAccounts that are in the bank*/
	private Vector<CheckingAccount> fCheckingAccounts;
	
	/** The SavingsAccounts that are in the bank*/
	private Vector<SavingsAccount> fSavingAccounts;
	
	/**
	 * Constructs a Bank with the given name
	 * @param name The name of the bank
	 */
	public Bank(String name)
	{
		fName = name;
		fCheckingAccounts = new Vector<CheckingAccount>();
		fSavingAccounts = new Vector<SavingsAccount>();
	}
	
	/**
	 * Opens a checking account.
	 * @return The checking account number
	 */
	public int openSimpleCheckingAccount()
	{
		Person p = new Person("Bob Smith", "1 Main St.", "12345", "Tacoma", "USA");
		CheckingAccount newAccount = new CheckingAccount(p);
		fCheckingAccounts.add(newAccount);
		return newAccount.getAccountNumber();
	}
	
	/**
	 * Opens a Checking and Savings account
	 * 
	 * @return The checking account number
	 */
	public int openFullPackage()
	{
		Person p = new Person("Bob Smith", "1 Main St.", "12345", "Tacoma", "USA");

		CheckingAccount newAccount = new CheckingAccount(p);
		fCheckingAccounts.add(newAccount);
		
		newAccount.applyForCreditCard(p, newAccount.getAccountNumber());
		SavingsAccount newSavingsAccount = new SavingsAccount(p);
		fSavingAccounts.add(newSavingsAccount);
		
		DebitCard newDebetCard = new DebitCard(p, 0, newAccount);
		return newAccount.getAccountNumber();
	}
	
	/**
	 * Method that withdraws the specified amount from the account number.
	 * @param accountNumber The account number to withdraw the money from
	 * @param amount The amount to withdraw 
	 * @return A boolean for if the money was withdrawn.
	 */
	public boolean withdrawMoney(int accountNumber, double amount)
	{
		CheckingAccount account = new CheckingAccount(accountNumber);
		int index = fCheckingAccounts.indexOf(account);
		return fCheckingAccounts.elementAt(index).withdrawal(amount);
	}
	
	/**
	 * Getter for the name of the bank
	 * @return THe name of the bank
	 */
	public String getName() {
		return fName;
	}
	
}
